<?php  
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

defined('_JEXEC') or die('Retricted Access');
JHTML::_('behavior.tooltip');
global $mainframe;
?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	
	if (pressbutton == 'save' && document.getElementById('global_config').checked && $("tax[tax_enable]1").checked ){
		var form = document.adminForm;
		
		if ( document.getElementById('tax_title').value == "" ) {
			alert("Global Tax Title is required");
			document.getElementById('tax_title').focus();
			return;
		}
		 
	    if( ! checkNumber(document.getElementById('tax_value').value) ){
	        alert("Global Tax Value is required and must be numberic value");
	        document.getElementById('tax_value').focus();
	        return false;
	    }	    
        
		submitform(pressbutton);		
	}
	else {		
		submitform(pressbutton);
	}
}

// Check numberic value
function checkNumber(value){    
	var numericExpression = /^[0-9]+$/;
	var numericExpression1 = /^[0-9]+\.[0-9]{1,2}$/;
	
	if ( value.match(numericExpression) || value.match(numericExpression1) )
	   return true
	else return false;
}

window.addEvent('domready', function() {
	changeGlobal();

	$('tax[tax_enable]1').addEvent('change', function (){
		changeGlobal();
	});
	
	$('tax[tax_enable]0').addEvent('change', function (){
		changeGlobal();
	});

});

function changeGlobal(){
	var display_tax_mode_ = 'none';
	var display_global_title_ = 'none';
	if($("tax[tax_enable]1").checked){
		display_tax_mode_ = 'block';
		if($("global_config").checked)
			display_global_title_ = 'block';
	}
	
	$("tax_mode_").style.display = display_tax_mode_;
	$("global_title_").style.display = display_global_title_;
}

</script>

<style type="text/css">
	td.key{
		font-weight:normal !important;
		text-align:left !important;
	}
	td.master{
		font-weight:bold !important;
	}
</style>

<form action="index.php" method="post" name="adminForm">
<div class="col100">
	<fieldset class="adminform">
		<?php echo $this->getTaxTabs();?>
	</fieldset>	
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'Global Tax Settings' ); ?></legend>		
		<table class="admintable" width="100%" id="tax_enable_">
		<tbody>
			<tr>
				<td width="120" class="key">
					<?php echo JText::_( 'Enable TAX' ); ?>:
				</td>
				<td >
					<?php
					$published = $this->params->get('tax_enable', "0");
					$lists['published'] = JHTML::_('select.booleanlist',  'tax[tax_enable]', 'class="inputbox"', $published );
					echo $lists['published']; ?>						
				</td>
			</tr>
		</tbody>
		</table>
		<table class="admintable" width="100%" id="tax_mode_">
		
			<tr>
				<td width="30%" class="key">
					<label for="currency"><?php echo JText::_( 'Using TAX method' ); ?></label>:
				</td>
				<td width="70%">
					<input onchange="changeGlobal();" type="radio" <?php if($this->params->get('tax_mode', "global")=='global') echo "checked";?> value="global" name="tax[tax_mode]" id="global_config"/>
					<?php echo JText::_( 'Global TAX Setting' ); ?><br/>					
					<input onchange="changeGlobal()" type="radio" <?php if($this->params->get('tax_mode', "global")=='regional') echo "checked";?> value="regional" name="tax[tax_mode]" id="regional_config"/>
					<?php echo JText::_( 'Regional TAX Setting' ); ?>
				</td>
			</tr>
		
		</table>
		<table class="admintable" width="100%" id="global_title_">
		<tbody>
			<tr>
				<td class="key "  width="30%" >
					<label for="tax_title"><?php echo JText::_( 'Global Tax Title' ); ?></label>:
				</td>
				<td  width="70%" >
					<input type="text" name="tax[global_title]" value="<?php echo $this->params->get('global_title');?>" id="tax_title"  size="50">
					<font color="red"> *</font>
				</td>
			</tr>
			<tr>
				<td class="key "  width="30%" >
					<label for="tax_value"><?php echo JText::_( 'Global Tax Value' ); ?></label>:
				</td>
				<td  width="70%" >
					<input type="text" name="tax[global_value]" value="<?php echo $this->params->get('global_value');?>" id="tax_value"  size="10"> % 
					<font color="red"> *</font>
				</td>
			</tr>		
		</tbody>
		</table>
	</fieldset>
</div>
<div class="clr"></div>
<input type="hidden" name="option" value="<?php echo JBCOMNAME; ?>" />
<input type="hidden" name="view" value="jaconfiguration" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="tab" value="tax" />
<input type="hidden" name="cid" value="<?php echo $this->cid; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>	
 </form>